<?php
$app = Blyn::app()->getActiveApp();
?>
<?php
$categoryNameField = 'media_name_event_category';
$categoryAliasField = 'media_alias_event_category';
$model->addField($categoryNameField);
$model->addField($categoryAliasField);

if ($eventId > 0) {
    //获取当前的活动
    $eventTable = new BPSheet('eventTable');
    $event = $eventTable->getListById($eventId);

    //获取当前活动的分类列表
    $eventCategoryTable = new BPCategorySheet('eventCategory', $event);
    $categoryView = $eventCategoryTable->getView();
}
?>
<?php echo '分类列表'; ?>
<table class="table table-hover">
    <colgroup>
        <col class="span1">
        <col class="span7">
    </colgroup>
    <thead>
        <tr>
            <th></th>
            <th><?php echo '分类全名'; ?></th>
            <th><?php echo '别名'; ?></th>
            <th><?php echo '操作'; ?></th>
        </tr>
    </thead>
    <tbody>
        <?php
        foreach ($categoryView as $id => $eventCategory) {
            $categoryId = $eventCategory->getItem('categoryId')->getValue();
            $category = new BPCategory($categoryId);
            ?>
            <tr><td><input type="checkbox" id=<?php echo $id; ?>></td>
                <td> <?php
                    echo $category->getFullName();
                    // echo $form->textField($model, $categoryEnglistField, array('placeholder' => 'English Name' . '...', 'required' => true));
                    ?> </td>
                <td>
                    <?php
                    echo $category->getValue();
                    //  echo $form->textField($model, $categoryEnglistField, array('placeholder' => '中文名称' . '...', 'required' => true));
                    ?>
                </td>
                <td>
                    <div class="row-fluid">                         
                        <?php
                        echo $control->getAjaxLink(array('name' => '修改', 'id' => 'modifyEventCategory'), array(
                            'eventId' => $eventId,
                        ));
                        echo " | ";
                        ?>                               
                        <?php
                        echo $control->getAjaxLink(array('name' => '删除', 'id' => 'deleteEventCategory'), array(
                            'eventId' => $eventId,
                        ));
                        ?> 
                    </div>                      
                </td>
            </tr> 
        <?php } ?>
    </tbody>
</table>

<table class="table table-hover">
    <colgroup>
        <col class="span1">
        <col class="span7">
    </colgroup>
    <thead>
        <tr>
            <th><?php echo '分类全名'; ?></th>
            <th><?php echo '别名'; ?></th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>
                <?php
                echo $form->textField($model, $categoryNameField, array('placeholder' => 'category full name' . '...', 'required' => true));
                ?>
            </td>
            <td>
                <?php
                echo $form->textField($model, $categoryAliasField, array('placeholder' => 'alias' . '...'));
                ?>
            </td>
            <td>
                <?php
                echo $control->getAjaxLink(array('id' => 'addEventCategory', 'name' => '添加分类'));
                ?>
            </td>
        </tr>               
    </tbody>
</table>
